Array.prototype.my_filter = function(fn, context) {

    let resArr = []
    const me = this

    const ctx = context ? context : this

    if (typeof fn !== 'function') {
        throw new Error(`${fn} is not a function`)
    }

    me.forEach((item, index) => {
        const bool = fn.call(ctx, item, index, me)
        if (bool) {
            resArr.push(item)
        }
    })

    return resArr
}

const arr = [1,2,3]
const arr1 = [4,5,6]

const newArr = arr.my_filter((item) => item > 1)

console.log(newArr)